﻿Ext.extend(NExt.form.TextField, Ext.form.TextField, {
    getModel: function() {
        if (Ext.isEmpty(this.displayField)) {
            var model = this.getValue();
            return model;
        }

        if (!Ext.isDefined(this.model)) {
            this.model = {};
        }
        var value = this.getValue();
        this.model[this.displayField] = value;
        return this.model;
    },

    setModel: function(model) {
        if (Ext.isEmpty(this.displayField)) {
            this.setValue(model);
            return;
        }

        this.model = model;
        var displayValue = this.model[this.displayField];
        this.setValue(displayValue);
    }
});